{"ast":null,"code":"import * as React from 'react';\nexport default function useSelectTriggerControl(elements, open, triggerOpen, customizedTrigger) {\n  var propsRef = React.useRef(null);\n  propsRef.current = {\n    open: open,\n    triggerOpen: triggerOpen,\n    customizedTrigger: customizedTrigger\n  };\n  React.useEffect(function () {\n    function onGlobalMouseDown(event) {\n      var _propsRef$current;\n\n      // If trigger is customized, Trigger will take control of popupVisible\n      if ((_propsRef$current = propsRef.current) !== null && _propsRef$current !== void 0 && _propsRef$current.customizedTrigger) {\n        return;\n      }\n      var target = event.target;\n      if (target.shadowRoot && event.composed) {\n        target = event.composedPath()[0] || target;\n      }\n      if (propsRef.current.open && elements().filter(function (element) {\n        return element;\n      }).every(function (element) {\n        return !element.contains(target) && element !== target;\n      })) {\n        // Should trigger close\n        propsRef.current.triggerOpen(false);\n      }\n    }\n    window.addEventListener('mousedown', onGlobalMouseDown);\n    return function () {\n      return window.removeEventListener('mousedown', onGlobalMouseDown);\n    };\n  }, []);\n}","map":{"version":3,"names":["React","useSelectTriggerControl","elements","open","triggerOpen","customizedTrigger","propsRef","useRef","current","useEffect","onGlobalMouseDown","event","_propsRef$current","target","shadowRoot","composed","composedPath","filter","element","every","contains","window","addEventListener","removeEventListener"],"sources":["/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/rc-select/es/hooks/useSelectTriggerControl.js"],"sourcesContent":["import * as React from 'react';\nexport default function useSelectTriggerControl(elements, open, triggerOpen, customizedTrigger) {\n  var propsRef = React.useRef(null);\n  propsRef.current = {\n    open: open,\n    triggerOpen: triggerOpen,\n    customizedTrigger: customizedTrigger\n  };\n  React.useEffect(function () {\n    function onGlobalMouseDown(event) {\n      var _propsRef$current;\n\n      // If trigger is customized, Trigger will take control of popupVisible\n      if ((_propsRef$current = propsRef.current) !== null && _propsRef$current !== void 0 && _propsRef$current.customizedTrigger) {\n        return;\n      }\n\n      var target = event.target;\n\n      if (target.shadowRoot && event.composed) {\n        target = event.composedPath()[0] || target;\n      }\n\n      if (propsRef.current.open && elements().filter(function (element) {\n        return element;\n      }).every(function (element) {\n        return !element.contains(target) && element !== target;\n      })) {\n        // Should trigger close\n        propsRef.current.triggerOpen(false);\n      }\n    }\n\n    window.addEventListener('mousedown', onGlobalMouseDown);\n    return function () {\n      return window.removeEventListener('mousedown', onGlobalMouseDown);\n    };\n  }, []);\n}"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,eAAe,SAASC,uBAAuB,CAACC,QAAQ,EAAEC,IAAI,EAAEC,WAAW,EAAEC,iBAAiB,EAAE;EAC9F,IAAIC,QAAQ,GAAGN,KAAK,CAACO,MAAM,CAAC,IAAI,CAAC;EACjCD,QAAQ,CAACE,OAAO,GAAG;IACjBL,IAAI,EAAEA,IAAI;IACVC,WAAW,EAAEA,WAAW;IACxBC,iBAAiB,EAAEA;EACrB,CAAC;EACDL,KAAK,CAACS,SAAS,CAAC,YAAY;IAC1B,SAASC,iBAAiB,CAACC,KAAK,EAAE;MAChC,IAAIC,iBAAiB;;MAErB;MACA,IAAI,CAACA,iBAAiB,GAAGN,QAAQ,CAACE,OAAO,MAAM,IAAI,IAAII,iBAAiB,KAAK,KAAK,CAAC,IAAIA,iBAAiB,CAACP,iBAAiB,EAAE;QAC1H;MACF;MAEA,IAAIQ,MAAM,GAAGF,KAAK,CAACE,MAAM;MAEzB,IAAIA,MAAM,CAACC,UAAU,IAAIH,KAAK,CAACI,QAAQ,EAAE;QACvCF,MAAM,GAAGF,KAAK,CAACK,YAAY,EAAE,CAAC,CAAC,CAAC,IAAIH,MAAM;MAC5C;MAEA,IAAIP,QAAQ,CAACE,OAAO,CAACL,IAAI,IAAID,QAAQ,EAAE,CAACe,MAAM,CAAC,UAAUC,OAAO,EAAE;QAChE,OAAOA,OAAO;MAChB,CAAC,CAAC,CAACC,KAAK,CAAC,UAAUD,OAAO,EAAE;QAC1B,OAAO,CAACA,OAAO,CAACE,QAAQ,CAACP,MAAM,CAAC,IAAIK,OAAO,KAAKL,MAAM;MACxD,CA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